Skip to content
This repository was archived by the owner on Jun 6, 2025. It is now read-only.

Conversation

@krystalcampioni
Copy link
Contributor

@krystalcampioni krystalcampioni commented Apr 30, 2021

What problem is this PR solving?

Solves: https://github.com/Shopify/core-issues/issues/23793

  • Implements gradients and updated hovering style subduing inactive bars

⚠️ This branch also introduces the following secondary changes:

  • SquarePreviewColor can now accept GradientStop[]
  • Removed duplicated component in favour of components/Bar
  • Stacked bar chart doesn't break if we pass in a gradient. This change was necessary since both chart types are defined within <MultiSeriesBarChart/>. Even though it works, we should revisit this chart later to check what would be the expected gradient behaviour and introduce animations:

Reviewers’ 🎩 instructions

Before merging

  • Check your changes on a variety of browsers and devices.

  • Update the Changelog.

  • Update relevant documentation.

@krystalcampioni krystalcampioni changed the title Remove <Bar> duplication, remove highlight color Use gradients and subduing in MultiSeriesBarChart Apr 30, 2021
@@ -1,17 +1,13 @@
import React, {useMemo} from 'react';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same component that lived in BarChart/components. I've just moved it up, since all Bars now use the same API

@@ -1,135 +1,95 @@
import React from 'react';
import {mount} from '@shopify/react-testing';
import {scaleBand} from 'd3-scale';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as mentioned above, just moving the Bar from BarChart/components up

Comment on lines +35 to +37

<SquareColorPreview color={color} />

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated this since now SquareColorPreView can handle both solid colors and gradients

const handleFocus = () => {
onFocus(barGroupIndex);
};
<mask id={maskId}>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same strategy used on the BarChart: masking a tag that contains the gradients

Comment on lines 75 to 84
<StackMarkup
data={data}
xScale={xScale}
onFocus={onFocus}
ariaHidden
activeBarId={activeBarId}
accessibilityData={accessibilityData}
activeBarGroup={activeBarGroup}
yScale={yScale}
groupIndex={groupIndex}
/>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Originally I was simply reusing the markup with a <use/> tag, but I had to convert it to a react component so I can aria-hide the duplicate and prevent them from being focusable

import {SquareColorPreview, SquareColorPreviewProps} from '../../../components';

export default {
title: 'SquareColorPreview',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move towards putting the components/subcomponents into their own storybook group.

Suggested change
title: 'SquareColorPreview',
title: 'Components/SquareColorPreview',

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a top level component though. What would be the benefit of it being separated from the other stories in its own folder? 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking that the charts would be in one group and all of the other components that make up the charts such as tooltips, legends, etc could be in another group.

@pbojinov
Copy link
Member

Something I noticed when testing the MultiSeriesBarChart with VoiceOver. When tabbing through the bars and the primary bar value is 0, the screen reader selection will select the whole chart. Not sure what's necessarily expected here so I wanted to share it here:

04-30-15-54-qcjaj-1j1pl.mp4

https://screenshot.click/04-30-15-54-qcjaj-1j1pl.mp4

@krystalcampioni krystalcampioni force-pushed the multiseries_bar_gradients branch from abaf030 to b92fffe Compare May 3, 2021 15:35
@krystalcampioni
Copy link
Contributor Author

@pbojinov I don't think that is a problem. The black square that appears around the element tries to highlight visually the element currently selected. If the value is 0 the element is indeed invisible, so it uses the chart as a fallback.

@krystalcampioni krystalcampioni force-pushed the multiseries_bar_gradients branch 2 times, most recently from 4e5cc07 to 3e2e5d5 Compare May 3, 2021 18:09
Copy link
Contributor

@carysmills carysmills left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code and 🎩 looks good to me
Left a suggestion about the types in StackedBarGroup

Can you please make sure to update MultiSeriesBarChart.md with the changes to the props, as well as the changelog?

@krystalcampioni krystalcampioni force-pushed the multiseries_bar_gradients branch from 3e2e5d5 to e46d3d9 Compare May 4, 2021 15:52
@krystalcampioni krystalcampioni force-pushed the multiseries_bar_gradients branch from e674bd0 to ad338b6 Compare May 4, 2021 15:59
@krystalcampioni krystalcampioni merged commit 17d16e8 into master May 4, 2021
@krystalcampioni krystalcampioni deleted the multiseries_bar_gradients branch May 4, 2021 16:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants